﻿using System.Windows.Forms;
using System.Timers;
using Paypayes.Aelda.Core.Server;
using System.Reflection;
using System.Linq;
using System;
using System.Collections.Generic;
using System.Text;
using Paypayes.Aelda.Core;

namespace Server
{
    public partial class Form1 : Form
    {
        ServerSimulation _world;
        private System.Timers.Timer _timer = null;
        public Form1()
        {
            _world = new ServerSimulation();
            _world.StartUp();
            InitializeComponent();

            // Defini le timer
            _timer = new System.Timers.Timer(250);
            _timer.Enabled = false;
            _timer.Elapsed += new ElapsedEventHandler(_timer_Elapsed);
        }

        void _timer_Elapsed(object sender, ElapsedEventArgs e)
        {
            _world.Tick();
        }

        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (_timer != null)
            {
                _timer.Dispose();
                _timer = null;
            }

            _world.ShutDown();
            _world.Dispose();
        }
    }
}
